package com.changsha.jacocotest.service;

import com.changsha.jacocotest.model.Student;
import org.springframework.stereotype.Service;

@Service
public class TestService2 {
    //学生成绩求平均值
    public double getAvgScore() {
        Student st1 =  new Student();
        st1.setScore(80);
        Student st2 =  new Student();
        st2.setScore(90);
        Student st3 =  new Student();
        st3.setScore(100);
        return (double) (st1.getScore() + st2.getScore() + st3.getScore()) / 3;
    }

    //学生成绩求中位数
    public double getMidScore() {
        Student st1 =  new Student();
        st1.setScore(85);
        Student st2 =  new Student();
        st2.setScore(90);
        Student st3 =  new Student();
        st3.setScore(100);
        if (st1.getScore() > st2.getScore()){
            if (st2.getScore() > st3.getScore()){
                return st2.getScore();
            } else {
                return st3.getScore();
            }
        }
        else {
            if (st1.getScore() > st3.getScore()){
                return st1.getScore();
            } else {
                return st3.getScore();
            }
        }
    }

}
